package com.mec.offload.service.impl;


import com.mec.offload.dao.NodeTermMapper;
import com.mec.offload.model.NodeTerm;
import com.mec.offload.model.OffloadSubTask;
import com.mec.offload.service.NodeTermService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NodeTermServiceImpl implements NodeTermService {
    @Autowired
    private NodeTermMapper nodeTermMapper;
    public List<NodeTerm> getAllNodeTerm(){
        try {
            return nodeTermMapper.getAllNodeTerm();
        }catch (Exception e){

            e.printStackTrace();
        }
        System.out.println("TermServiceImpl error");
        return null;
    }
    public int updateNodeTerm(NodeTerm nodeTerm)
    {
        try {
            return nodeTermMapper.updateNodeTerm(nodeTerm);
        }catch (Exception e){
            e.printStackTrace();
        }
        return 0;
    }
    public int deleteNodeTerm(NodeTerm nodeTerm)
    {
        try {
            return nodeTermMapper.deleteNodeTerm(nodeTerm);
        }catch (Exception e){
            e.printStackTrace();
        }
        return 0;
    }
    public NodeTerm findNodeTerm(Integer id)
    {
        try {
            return nodeTermMapper.findNodeTerm(id);
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
    public NodeTerm getOriTaskTerm(Integer TaskId){
        try {
            return nodeTermMapper.getOriTaskTerm(TaskId);
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }
    public int updateThroughPut(OffloadSubTask offloadSubTask){
        try {
           return nodeTermMapper.updateThroughPut(offloadSubTask);
        }catch (Exception e){
            e.printStackTrace();
            return -1;
        }
    }
    public int queryAllCount(){
        return nodeTermMapper.queryAllCount();
    }
    public List<NodeTerm>queryAllDataFromTable(int page, int limit){
        page=(page-1)*limit;
        return nodeTermMapper.queryAllDataFromTable(page,limit);
    }
}
